const { ESLint } = require('eslint');
const path = require('path');

async function testPlugin() {
  const eslint = new ESLint({
    useEslintrc: true,
    cwd: __dirname
  });

  try {
    const testFilePath = path.join(__dirname, 'test-file.js');
    const results = await eslint.lintFiles([testFilePath]);
    
    console.log('ESLint 检查结果:');
    console.log('================');
    
    results.forEach(result => {
      console.log(`文件: ${result.filePath}`);
      console.log(`错误数量: ${result.errorCount}`);
      console.log(`警告数量: ${result.warningCount}`);
      
      if (result.messages.length > 0) {
        console.log('\n错误详情:');
        result.messages.forEach(message => {
          console.log(`  ${message.line}:${message.column} - ${message.message}`);
        });
      }
      console.log('\n');
    });
  } catch (error) {
    console.error('测试失败:', error.message);
  }
}

testPlugin(); 